<?
/**
 * Copyright 2007 Melange.
 *
 * This file is part of PHP-MELANGE.
 *
 * PHP-MELANGE is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * PHP-MELANGE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PHP-MELANGE; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category    Melange
 * @package     php-melange
 * @subpackage  cms
 * @copyright   Copyright (c) 2007 Jeroen Simons. All rights reserved
 * @author      Jeroen Simons <jeroen@melange.nl>
 * @link        http://www.melange.nl/
 *
 */
?>
<?=$this->header()?>


    <?=$this->menu("setting")?>


    <h1><?=$this->message("label.header", _Setting::BUNDLE)?></h1>


    <? /* Breadcrums route & page info display */ ?>
    <?=$this->route($this->message("label.header", _Setting::BUNDLE))?>


    <? /* Show status messages */ ?>
    <?=$this->messages(_Core::BUNDLE)?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null, _Setting::BUNDLE)?>


    <form id="<?=get_class($this->settingForm)?>" method="post" action="setting/save">

        <fieldset>

            <legend><?=$this->message("label.language", _Setting::BUNDLE)?></legend>

            <table cellspacing="0" cellpadding="0" class="settings">
            <tr class="ctrl<?=$this->error("code")?>">
                <th class="narrow">
                    <input name="code"
                           id="code1"
                           value="nl"
                           type="radio"
                           class="radio"
                           <?=$this->settingForm->getCode() == "nl" ? " checked=\"checked\"" : ""?> />
                </th>
                <th class="flag">
                    <img src="static.php?file=<?=$this->image("cms/core/view/gfx/flag/nl.png")?>"
                         width="16" height="11" alt="Nederlands" title="Nederlands" />
                </th>
                <th><label for="code1"><?=$this->message("prompt.dutch", _Setting::BUNDLE)?></label></th>
            </tr>
            <tr class="ctrl<?=$this->error("code")?>">
                <th class="narrow">
                    <input name="code"
                           id="code2"
                           value="en"
                           type="radio"
                           class="check"
                           <?=$this->settingForm->getCode() == "en" ? " checked=\"checked\"" : ""?> />
                </th>
                <th class="flag">
                    <img src="static.php?file=<?=$this->image("cms/core/view/gfx/flag/en.png")?>"
                         width="16" height="11" alt="English" title="English" />
                </th>
                <th>
                    <label for="code2">                        
                        <?=$this->message("prompt.english", _Setting::BUNDLE)?>
                    </label>
                </th>
            </tr>
            </table>


        </fieldset>

        <? /* Hide i18n if disabled */ ?>
        <? if($this->param(_Core::I18N)): ?>

            <fieldset>

                <legend><?=$this->message("label.languages", _Setting::BUNDLE)?></legend>

                <table cellspacing="0" cellpadding="0" class="settings">
                <tr class="ctrl<?=$this->error("codes")?>">
                <?
                $languages = $this->languages($this->settingForm->more());
                $count = 0;
                for($j=0; $j<count($languages); $j++): ?>

                    <th class="narrow">
                        <input name="codes[]"
                               value="<?=$languages[$j]->getCode()?>"
                               id="<?=$languages[$j]->getCode()?>"
                               type="checkbox"
                               class="check"
                               <?=in_array($languages[$j]->getCode(), $this->settingForm->getCodes()) ? " checked=\"checked\"" : ""?>
                               <?=$languages[$j]->getCode() == $this->param(_Core::DEFAULT_LANGUAGE) ? " disabled=\"disabled\"" : ""?> />
                    </th>
                    <th class="flag">
                        <? if($languages[$j]->getImage()): ?>
                            <img src="static.php?file=<?=$this->image("cms/core/view/gfx/flag/".$languages[$j]->getCode().".png")?>"
                                 width="16" height="11" title="<?=$languages[$j]->getName()?>"
                                 alt="<?=$languages[$j]->getName()?>" />
                        <? endif; ?>
                    </th>
                    <th><label for="<?=$languages[$j]->getCode()?>"><?=$languages[$j]->getName()?></label></th>

                <? if(++$count == 4): ?>

                    <? $count = 0; ?>

                    </tr>
                    <tr class="ctrl<?=$this->error("codes")?>">

                <? endif; ?>

                <? endfor; ?>

                    <th colspan="12">
                        <? if(!$this->settingForm->more()): ?>
                        <input type="hidden" name="more" value="0" />
                        <a href="javascript:more('<?=get_class($this->settingForm)?>');"><?=$this->message("label.more", _Core::BUNDLE)?></a>
                        <p class="hint"><?=$this->message("note.submit.changes", _Core::BUNDLE)?></p>
                        <? endif; ?>
                    </th>
                </tr>
                </table>


            </fieldset>

        <? endif; ?>

        <div class="buttons" style="padding-left:20px">

            <input type="submit"
                   value="<?=$this->message("button.submit", _Core::BUNDLE)?>"
                   class="button" />

        </div>


    </form>

<?=$this->footer("settings")?>